package zuoye.zuoye2;

import java.util.Arrays;
import java.util.Comparator;

public class Test {
    public static void main(String[] args) {
        Student[] students = {
                new Student("张三", 20, "男", 180, 95),
                new Student("李四", 19, "女", 190.5, 80),
                new Student("王五", 20, "男", 165.5, 90),
                new Student("赵六", 20, "女", 185.5, 85.5),
                new Student("孙七", 22, "男", 170.5, 100),
        };
        Arrays.sort(students, (Student o1, Student o2) -> {
            if (o1.getAge() == o2.getAge()) {
                return Double.compare(o2.getScore(), o1.getScore());
            }
            return o1.getAge() - o2.getAge();
        });
        for (int i = 0; i < students.length; i++) {
            System.out.println(students[i]);
        }


    }
}
